
#include "NoticeCommon.h"
#include "../share/StringFactory.h"
#include "../share/user_define.h"

//-------------------------------------------------------------------------------
NoticeCommon::NoticeCommon(void)
	: m_option_1(nullptr)
	, m_option_2(nullptr)
	, m_option_3(nullptr)
	, m_user_1(0)
	, m_user_2(0)
	, m_user_3(0)
{
	_safe_guard_begin;
	_safe_guard_end;
}

//-------------------------------------------------------------------------------
NoticeCommon::~NoticeCommon(void)
{
	clear();
}

//-------------------------------------------------------------------------------
void NoticeCommon::NoticeStart(void)
{
	_safe_guard_begin;

	clear();

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::NoticeFinish(void)
{
	_safe_guard_begin;
	
	Display();

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::SetOption1(const char* val)
{
	_safe_guard_begin;
	
	m_option_1 = string_factory::CreateString(val);

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::SetOption2(const char* val)

{
	_safe_guard_begin;

	m_option_2 = string_factory::CreateString(val);

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::SetOption3(const char* val)
{
	_safe_guard_begin;

	m_option_3 = string_factory::CreateString(val);

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::SetUserVal1(uint32_t val)
{
	_safe_guard_begin;
	
	m_user_1 = val;

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::SetUserVal2(uint32_t val)
{
	_safe_guard_begin;

	m_user_2 = val;

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::SetUserVal3(uint32_t val)
{
	_safe_guard_begin;
	
	m_user_3 = val;

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
void NoticeCommon::Display(void)
{
	_safe_guard_begin;
	
	//std::cout << std::endl;
	//std::cout
	//	<< "UserDef_1: " << m_user_1 << '\t'
	//	<< "UserDef_2: " << m_user_2 << '\t'
	//	<< "UserDef_3: " << m_user_3 << std::endl;
	//if (m_option_1)
	//	std::cout << *m_option_1 << std::endl;
	//if (m_option_2)
	//	std::cout << *m_option_2 << std::endl;
	//if (m_option_3)
	//	std::cout << *m_option_3 << std::endl;

	_safe_guard_end;
}

//-------------------------------------------------------------------------------
std::string * NoticeCommon::GetOption1(void)
{
	_safe_guard_begin;

	return m_option_1;

	_safe_guard_end;

	return nullptr;
}

//-------------------------------------------------------------------------------
std::string * NoticeCommon::GetOption2(void)
{
	_safe_guard_begin;

	return m_option_2;

	_safe_guard_end;

	return nullptr;
}

//-------------------------------------------------------------------------------
std::string * NoticeCommon::GetOption3(void)
{
	_safe_guard_begin;

	return m_option_3;

	_safe_guard_end;

	return nullptr;
}

//-------------------------------------------------------------------------------
uint32_t NoticeCommon::GetUserVal1(void)
{
	_safe_guard_begin;

	return m_user_1;

	_safe_guard_end;

	return 0;
}

//-------------------------------------------------------------------------------
uint32_t NoticeCommon::GetUserVal2(void)
{
	_safe_guard_begin;

	return m_user_2;

	_safe_guard_end;

	return 0;
}

//-------------------------------------------------------------------------------
uint32_t NoticeCommon::GetUserVal3(void)
{
	_safe_guard_begin;

	return m_user_3;

	_safe_guard_end;

	return 0;
}

//-------------------------------------------------------------------------------
void NoticeCommon::clear(void)
{
	_safe_guard_begin;

	if (m_option_1)
	{
		string_factory::FreeString(m_option_1);
		m_option_1 = nullptr;
	}
		

	if (m_option_2)
	{
		string_factory::FreeString(m_option_2);
		m_option_2 = nullptr;
	}
		

	if (m_option_3)
	{
		string_factory::FreeString(m_option_3);
		m_option_3 = nullptr;
	}
		

	m_user_1 = 0;
	m_user_2 = 0;
	m_user_3 = 0;
		
	_safe_guard_end;
}
